﻿using System;
using Croxweb.Leuphana.Models;
using System.Windows;


namespace Croxweb.Leuphana.ViewModels
{
    public class AppointmentViewModel : ViewModelBase
    {
        private readonly Appointment appointment;

        private Boolean showDate = true;
        private Boolean showTime = true;

        public AppointmentViewModel()
        {
            this.appointment = new Appointment();
        }

        public AppointmentViewModel(Appointment appointment)
        {
            this.appointment = appointment;
        }

        public int Id
        {
            get { return appointment.Id; }
            set
            {
                appointment.Id = value;
                NotifyPropertyChanged("Id");
            }
        }

        public int LectureId
        {
            get { return appointment.LectureId; }
            set
            {
                appointment.LectureId = value;
                NotifyPropertyChanged("LectureId");
            }
        }

        public String Lecture
        {
            get { return appointment.Lecture; }
            set
            {
                appointment.Lecture = value;
                NotifyPropertyChanged("Lecture");
            }
        }

        public String Subject
        {
            get { return appointment.Subject; }
            set
            {
                appointment.Subject = value;
                NotifyPropertyChanged("Subject");
            }
        }

        public String Notes
        {
            get { return appointment.Lecture; }
            set
            {
                appointment.Lecture = value;
                NotifyPropertyChanged("Notes");
            }
        }

        public String Location
        {
            get { return appointment.Location; }
            set
            {
                appointment.Location = value;
                NotifyPropertyChanged("Location");
            }
        }

        public DateTime StartDate
        {
            get { return appointment.StartDate; }
            set
            {
                appointment.StartDate = value;
                NotifyPropertyChanged("StartDate");
            }
        }

        public DateTime EndDate
        {
            get { return appointment.EndDate; }
            set
            {
                appointment.EndDate = value;
                NotifyPropertyChanged("StartDate");
            }
        }

        public DateTime StartTime
        {
            get { return appointment.StartTime; }
            set
            {
                appointment.StartTime = value;
                NotifyPropertyChanged("StartTime");
            }
        }

        public DateTime EndTime
        {
            get { return appointment.EndTime; }
            set
            {
                appointment.EndTime = value;
                NotifyPropertyChanged("EndTime");
            }
        }

        public String TimeSpan
        {
            get { return appointment.StartTime.ToShortTimeString() + " – " + appointment.EndTime.ToShortTimeString(); }
        }

        public String DateSpan
        {
            get { return StartDate.ToString("dddd") + ", " + StartDate.ToShortDateString() + " - " + EndDate.ToShortDateString(); }
        }

        public RecurrenceType Recurrence
        {
            get { return appointment.Recurrence; }
            set
            {
                appointment.Recurrence = value;
                NotifyPropertyChanged("Recurrence");
            }
        }

        public String ShortDate
        {
            get { return appointment.StartDate.ToShortDateString(); }
        }

        public String LongDate
        {
            get { return appointment.StartDate.ToLongDateString(); }
        }

        public Visibility ShowDate
        {
            get { return showDate ? Visibility.Visible : Visibility.Collapsed; }
            set
            {
                showDate = (value == Visibility.Visible) ? true : false;
                NotifyPropertyChanged("ShowDate");
            }
        }

        public Visibility ShowTime
        {
            get { return showTime ? Visibility.Visible : Visibility.Collapsed; }
            set
            {
                showTime = (value == Visibility.Visible) ? true : false;
                NotifyPropertyChanged("ShowTime");
            }
        }
    }
}
